#!/usr/bin/make -f

#export DH_VERBOSE = 1

# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

export DPKG_EXPORT_BUILDFLAGS = 1

include /usr/share/dpkg/default.mk
export JAVA_HOME=/usr/lib/jvm/default-java

%:
	dh $@ --list-missing --parallel --with python2 --with=systemd --with javahelper

override_dh_auto_configure:
	dh_auto_configure -- \
	  -DBUILDDOC=ON \
	  -DBUILDSWIGPYTHON=ON \
	  -DBUILDSWIGNODE=ON \
	  -DBUILDSWIGJAVA=ON \
	  -DFIRMATA=ON \
	  -DINSTALLTOOLS=ON \
	  -DIMRAA=on

override_dh_install:
	dh_install
	jh_installlibs -plibmraa-java

override_dh_auto_test:
	dh_auto_test
	# fixup after the tests - remove rpath
	find $(CURDIR) -type f -name '_mraa.so' | xargs /usr/bin/chrpath -d

override_dh_installdocs:
	# fix lintian useless-autogenerated-doxygen-file
	dh_installdocs -X.md5
	# fix lintian embedded-javascript-library
	#find debian -name jquery.js -exec ln -sfv /usr/share/javascript/jquery/jquery.js {} \;
	#find debian -name underscore.js -exec ln -sfv /usr/share/javascript/underscore/underscore.js {} \;

override_dh_strip:
	dh_strip -plibmraa1 --dbg-package=libmraa1-dbg
	dh_strip -pmraa-tools --dbg-package=mraa-tools-dbg
	dh_strip -ppython-mraa --dbg-package=python-mraa-dbg
	dh_strip -ppython3-mraa --dbg-package=python3-mraa-dbg
	dh_strip -plibmraa-java --dbg-package=libmraa-java-dbg
